import userStore, { IUserStore } from './userStore';
import EditorStore, { IEditorStore } from './editor';
import CateConfig, { ICateConfig } from './cateConfig';
import CateTypeStore, { ICateTypeStore } from './cateType';
import FileMagage,{IFileMagageStore} from './fileMagage'


const stores = (initialValue: Record<string, any>) => ({
    user: { ...userStore(), ...initialValue?.user } as IUserStore,
    editorInfo: { ...EditorStore(), ...initialValue?.editorInfo as IEditorStore},
    cateConfig: { ...CateConfig(), ...initialValue?.cateConfig as ICateConfig},
    cateTypeStore: { ...CateTypeStore(), ...initialValue?.cateTypeStore as ICateTypeStore},
    fileMagage: { ...FileMagage(), ...initialValue?.fileMagage as IFileMagageStore},
})

export type IStore = ReturnType<typeof stores>

export default function createStore(initialValue: any): () => IStore {
    return () => {
        return stores(initialValue)
    };
}